// 住院患者病历预览
import React, { Component } from 'react';
import { Card, Row, Col, Input, Select, Button, Table, Switch, message, Popconfirm, Modal } from 'antd';
import { $http } from 'containers/config/https';
import store from 'store';
import Moment from 'moment';
import { dayFormat, Util } from 'tools/index';
import iconListvisits from 'assets/images/icon_listvisits.png';
import CommonPagination from 'components/pagination/index';
import RangeDatePicker from 'components/rangePicker/index';
import ColumnAuthoritysModel from 'pages/columnAuthority/ColumnAuthoritysModel';
import CaseInformationPage from 'pages/workstation/component/CaseInformationPage.jsx';
import CaseInformationPageHospital from 'pages/workstation/component/CaseInformationPageHospital.jsx';

const { Option } = Select;
class PreviewPatientEMRRecord extends Component {
  constructor(props) {
    super(props);
    var userData = JSON.parse(sessionStorage.getItem('userData'));
    this.state = {
      userData,
      patientColumns: [],
      tableData: [],
      total: 0,
      page: 1,
      pageSize: 50,
      patientWidth: 0,
      basicHeight: 0,
      loading: false,
      patMessage: undefined, // 人员标识
      medicalNo: undefined, // 住院号
      bedID: undefined, // 床号
      locID: userData && userData.locID ? userData.locID : undefined, // 科室名称
      locSelectData: [],
      bedData: [],
      medicalRecordTemplateSelectData: [],
      medicalRecordTemplateID: undefined,
      rowId: "",
      rowRow: {},
      admStatusCode: undefined, // 患者类型
      admStatusSelectData: [],
      admTypeSelectData: [],
      admissionDate: undefined,
      dateFrom: undefined,
      dateTo: undefined,
      admSTDate: undefined,
      admSPDate: undefined,
      locType: "O^I^E^W^OI^OP",
      admStatusAble: false,
      bedIDAble: false,
      medicalNoAble: false,
      isSubmit: "ALL",
      submitSelectData: [],
      locDocData: [],
      admDocID: undefined, // 主管医生
      docNameAble: false,
      currentEMRStatus: '',// 病历状态
      btnStatus: 'N', //审核。归档按钮状态
      backOffBtnStatus: "N",//退回按钮状态 
      visible: false,//病案号输入框
      admMedicalNo: '', //病案号
      btnTips: "",
      backOffBtnTips: "",
      selectedRowKeys: [],  //选中行集合
    };
    this.myRef1 = React.createRef();
  }

  componentDidMount() {
    this.setState({ basicHeight: document.getElementById("patient-medical-record-inquiry-basic").clientHeight }, () => {
      setTimeout(() => {
        this.myRef1 && this.myRef1.current && this.myRef1.current.focus();
      }, 300)
    });
    this.getAdmTypeSelect();
    this.getPatAdmStatus();
    this.getEMRStatusSelect();
    this.getPatientColumns();
    this.initDefaultValue()
    this.handleQuery();
    this.loadBedData();
    this.getMedicalRecordTemplateSelectData();
  }

  //获取就诊类型下拉框
  getAdmTypeSelect = () => {
    let data = {}
    $http.post('urlS', this, {
      code: '03050088',
      data: data,
      success: function (res) {
        if (res.errorCode == 0) {
          this.setState({
            admTypeSelectData: res.result.Data
          })
        }
      }
    })
  }

  /**查询患者就诊状态数据 */
  getPatAdmStatus = () => {
    let data = { params: [{}] }
    $http.post('urlS', this, {
      code: '06080006',
      data: data,
      success: function (res) {
        if (res.errorCode == 0) {
          this.setState({
            admStatusSelectData: res.result.data
          })
        }
      }
    })
  }

  /**
   * 查询病历状态下拉框
   */
  getEMRStatusSelect = () => {
    let data = {}
    $http.post('urlS', this, {
      code: '06080005',
      data: data,
      success: function (res) {
        if (res.errorCode == 0) {
          this.setState({
            submitSelectData: res.result.data
          })
        }
      }
    })
  }
  //查询默认数据
  initDefaultValue = () => {
    let data = {
      params: [{
        defaultAppObj: {
          EMRBaseConfiger: ["PreviewOfPatEMRLocType", "PreviewOfPatEMRDefStatus", "PreviewOfPatAdmDefStatus"],
        }
      }]
    }
    $http.post('urlS', this, {
      code: "04110023",
      data: data,
      success: (res) => {
        if (+res.errorCode === 0) {
          const regex = /@/g;
          this.setState({
            // defaultValueObj: res.result,
            locType: res.result.PreviewOfPatEMRLocType ? (res.result.PreviewOfPatEMRLocType.replace(regex, '^')) : this.state.locType,
            isSubmit: res.result.PreviewOfPatEMRDefStatus ? (res.result.PreviewOfPatEMRDefStatus.replace(regex, '^')) : this.state.isSubmit,
            admStatusCode: res.result.PreviewOfPatAdmDefStatus ? (res.result.PreviewOfPatAdmDefStatus.replace(regex, '^')) : this.state.admStatusCode,
          }, () => {
            this.getLocSelectData();
          })
        }
      }
    })
  }

  // 获取病历模板下拉数据
  getMedicalRecordTemplateSelectData = () => {
    var params = {
      params: [{
        findTemp: "RELEASED"
      }]
    }
    $http.post('urlDeault', this, {
      code: "06050018",
      data: params,
      success: function (res) {
        if (+res.errorCode === 0) {
          let medicalRecordTemplateSelectData = res.result && res.result.data.length > 0 ? res.result.data : [];
          let medicalRecordTemplateID = medicalRecordTemplateSelectData && medicalRecordTemplateSelectData.length > 0 ? medicalRecordTemplateSelectData[0].id : undefined;
          this.setState({
            medicalRecordTemplateSelectData,
            medicalRecordTemplateID
          })
        }
      }
    });
  }

  //获取护理分组
  getLocSelectData = () => {
    let { userData, locType, locID } = this.state;
    let data = {
      params: [{
        hospID: userData && userData.hospID ? userData.hospID : "",
        type: locType,
        docFlag: "1",
      }]
    }
    $http.post('urlS', this, {
      code: "04020008",
      data: data,
      success: function (res) {
        if (+res.errorCode === 0) {
          let locSelectData = res.result && res.result.Data && res.result.Data.length > 0 ? res.result.Data : [];
          let allLocID = [];
          let locDoctor = [];
          let existUserLocIDFlag = false
          for (var i = 0; i < locSelectData.length; i++) {
            allLocID.push(locSelectData[i].id);
            if (locSelectData[i].code === "zhybek" || locSelectData[i].code === "zhybyk") {
              locDoctor = locDoctor.concat(locSelectData[i].locDoctor)
            }
            if ((!existUserLocIDFlag) && (locSelectData[i].id === locID)) { existUserLocIDFlag = true }
          }
          let allLoc = {
            id: "all",
            descripts: "全部",
            descriptsSPCode: "qu",
            allLocID,
            locTypeCode: "I",
            locTypeDesc: "住院",
            locDoctor: Util.unique(locDoctor, "id")
          }
          // console.log(allLoc)
          locID = existUserLocIDFlag ? locID : (locSelectData.length > 0 ? locSelectData[0].id : undefined)
          locSelectData.unshift(allLoc);
          this.setState({
            locSelectData,
            locID: locID,
          }, () => {
            this.handleLocIDChange(locID ? locID : "")
          })
        } else {
          this.setState({ locSelectData: [] })
        }
      }
    })
  }

  loadBedData = () => {
    let { locID } = this.state;
    if (!locID) return;
    var params = {
      params: [{
        locID, // userData && userData.locID ? userData.locID : ""
      }]
    }
    $http.post('urlDeault', this, {
      code: "03060005",
      data: params,
      success: function (res) {
        if (+res.errorCode === 0) {
          this.setState({
            bedData: res.data
          })
        }
      }
    });
  }

  // 获取患者表头数据
  getPatientColumns = () => {
    let data = {
      params: [{
        compontName: "PreviewOfPatEMRPatList",
        type: "C",
      }]
    }
    $http.post('urlDeault', this, {
      code: "01040073",
      data: data,
      success: (res) => {
        if (+res.errorCode === 0) {
          var columns = res.result.C;
          var dynColumns = []
          for (var i = 0; i < columns.length; i++) {
            dynColumns.push({
              title: columns[i].title,
              dataIndex: columns[i].dataIndex,
              width: parseInt(columns[i].width),
              align: columns[i].align || 'center'
            })
          }
          this.setState({
            patientColumns: dynColumns,
            patientWidth: res.totalWidth
          })
        }
      }
    })
  }

  onColumnRef = (ref) => {
    this.columnRef = ref;
  }

  // 查询条件 --- 人员标识
  handlePatMessageChange = e => {
    this.setState({ patMessage: e.target.value })
  }

  // 查询条件 --- 住院号
  handleMedicalNoChange = e => {
    this.setState({ medicalNo: e.target.value })
  }

  // 病案号
  handleAdmMedicalNoChange = e => {
    this.setState({ admMedicalNo: e.target.value })
  }

  // 查询条件 --- 床号
  handleBedIDChange = e => {
    this.setState({ bedID: e }, () => {
      this.handleQuery();
    })
  }

  // 查询条件 --- 主管医生
  handleAdmDocChange = e => {
    this.setState({ admDocID: e }, () => {
      this.handleQuery();
    })
  }

  // 查询条件 --- 科室名称
  handleLocIDChange = e => {
    let locTypeCode = ""
    let { locSelectData, locDocData, admDocID } = this.state
    let selLocDocData = []
    let selectLocAry = locSelectData.filter((item, index) => (item.id === e))
    if (selectLocAry.length > 0) {
      locTypeCode = selectLocAry[0].locTypeCode
      selLocDocData = selectLocAry[0].locDoctor
    }
    this.setState({
      locID: e,
      // admStatusCode: undefined, 
      admDocID: undefined,
      admStatusAble: ((locTypeCode !== "W") & (locTypeCode !== "I")) ? true : false,
      bedIDAble: ((locTypeCode !== "W") & (locTypeCode !== "I")) ? true : false,
      medicalNoAble: ((locTypeCode !== "W") & (locTypeCode !== "I")) ? true : false,
      locDocData: selLocDocData
    }, () => {
      this.handleQuery();
      this.loadBedData();
    })
  }

  // 查询
  handleQuery = () => {
    this.setState({ page: 1 }, () => {
      this.getTableData();
    })
  }

  getAllLocID = () => {
    let { locSelectData, locID } = this.state;
    let allLocID = [];
    for (var i = 0; i < locSelectData.length; i++) {
      if (locSelectData[i].id === locID) {
        allLocID = locSelectData[i].allLocID;
      }
    }
    return allLocID;
  }

  // 获取患者列表数据
  getTableData = (isRefresh) => {
    let { admTypeCode, userData, patMessage, bedID, medicalNo, locID, admStatusCode, page, pageSize, admissionDate, dateFrom, dateTo, admSTDate, admSPDate, isSubmit, admDocID } = this.state;
    let data = {
      params: [{
        admTypeCode: admTypeCode,
        locID: locID === "all" ? this.getAllLocID() : locID, // userData && userData.locID ? userData.locID : "",
        // userID: 164, // userData && userData.userID ? userData.userID : "",
        hospID: userData && userData.hospID ? userData.hospID : "",
        patMessage,
        bedID,
        medicalNo,
        admStatusCode,
        admissionDate: admissionDate ? Moment(admissionDate).format('YYYY-MM-DD') : undefined,
        dateFrom: admStatusCode === 'D' ? dateFrom : '',
        dateTo: admStatusCode === 'D' ? dateTo : '',
        admSTDate: admStatusCode !== 'D' ? admSTDate : '',
        admSPDate: admStatusCode !== 'D' ? admSPDate : '',
        IsSubmit: isSubmit,
        purpose: "PreviewPatRecord",
        componentCode: "PreviewOfPatEMRPatList", // 组件名称
        admDocID
      }],
      pagination: [{
        pageSize,
        currentPage: page
      }]
    }
    $http.post('urlDeault', this, {
      code: "06080002",
      data: data,
      success: function (res) {
        if (+res.errorCode === 0) {
          if (isRefresh === "noRefresh") {
            this.setState({ // 一键提交后不更新选中数据
              tableData: res.result.data,
              total: res.result.totalCount,
            })
          } else {
            this.setState({
              tableData: res.result.data,
              total: res.result.totalCount,
              rowId: "",
              rowRow: {},
              selectedRowKeys: [],
            })
          }
        } else {
          this.setState({
            tableData: [],
            total: 0,
            rowId: "",
            rowRow: {},
            selectedRowKeys: [],
          })
        }
      }
    });
  }

  // 患者列表 -- 条数改变的回调
  handleLeftShowSizeChange = (current, size) => {
    this.setState({ page: 1, pageSize: size }, () => {
      this.getTableData();
    });
  }

  // 患者列表 -- 页码改变的回调
  handleLeftChange = (page, pageSize) => {
    this.setState({ page, pageSize }, () => {
      this.getTableData();
    });
  }

  // 操作行 --- 患者列表
  onClickRowPublic = (record) => {
    const selectedRowKeys = [...this.state.selectedRowKeys];
    return {
      // 单击行选中，可加入多选集合中
      onClick: () => {
        /**只有提交状态可多选审核 */
        if (record.EMRStatusedCode && record.EMRStatusedCode === "F") {
          if (selectedRowKeys.indexOf(record.admID) >= 0) {
            selectedRowKeys.splice(selectedRowKeys.indexOf(record.admID), 1)
          } else { selectedRowKeys.push(record.admID) }
          this.setState({ selectedRowKeys: selectedRowKeys })
        }
        if (this.state.rowId === '') {
          // 保存行数据以及ID
          this.setState({
            rowId: record.admID,
            rowRow: record,
          }, () => {
            this.getPatEMRCurrentStatus();
            this.getPatEMRCurrentStatus("R");
            this.setPatientData();
          })
        } else {
          if (this.state.rowId !== record.admID) {
            this.setState({
              rowId: record.admID,
              rowRow: record,
            }, () => {
              this.getPatEMRCurrentStatus();
              this.getPatEMRCurrentStatus("R");
              this.setPatientData();
            })
          }
        }
      }
      // 双击
    }
  }

  setPatientData = () => {
    let { rowRow } = this.state;
    var patientData = {
      admID: rowRow?.admID,
      patID: rowRow?.patID,
    }
    sessionStorage.setItem('patientData', JSON.stringify(patientData));
  }

  getPatEMRCurrentStatus = (statusCode) => {
    var findStatusCode = statusCode;
    if (statusCode == undefined) {
      if (this.state.userData.groupDesc.indexOf("医师") > -1) {
        findStatusCode = "A"
      } else {
        findStatusCode = "AR"
      }
    }
    let { rowId, userData } = this.state;
    if (!rowId) return;
    let data = {
      params: [{
        statusCode: findStatusCode,
        admID: rowId,
      }]
    }
    $http.post('urlS', this, {
      code: "06050025",
      data: data,
      success: function (res) {
        console.log(res);
        if (+res.errorCode === 0) {
          if (statusCode != undefined) {
            this.setState({
              currentEMRStatus: res.result.currentStatusCode,// 病历状态 
              backOffBtnStatus: res.result.btnStatus,//退回按钮状态 
              backOffBtnTips: res.result.tips,//退回按钮状态 
            })
          } else {
            this.setState({
              currentEMRStatus: res.result.currentStatusCode,// 病历状态 
              btnStatus: res.result.btnStatus, //审核。归档按钮状态
              btnTips: res.result.tips,//退回按钮状态 
            })
          }
        }
      }
    })
  }

  setRowClassNamePublic = (record) => {
    return record.admID === this.state.rowId ? 'clickRowStyle' : "";
  }

  handleAdmTypeCodeChange = e => {
    this.setState({
      admTypeCode: e,
      admStatusAble: (e !== "I") ? true : false, bedIDAble: (e !== "I") ? true : false, medicalNoAble: (e !== "I") ? true : false
    }, () => {
      this.handleQuery();
    })
  }

  handleAdmStatusCodeChange = e => {
    this.setState({ admStatusCode: e }, () => {
      if (e === "D") {
        message.info("请选择出院开始截至日期进行查询！！！", 2)
      } else {
        this.handleQuery();
      }
    })
  }

  handleAdmissionDateChange = e => {
    this.setState({ admissionDate: e })
  }

  startChange = (e) => {
    this.setState({
      dateFrom: e ? Moment(e).format(dayFormat) : ''
    })
  }

  handleAdmSTDStartChange = (e) => {
    this.setState({
      admSTDate: e ? Moment(e).format(dayFormat) : ''
    })
  }

  endChange = (e) => {
    this.setState({
      dateTo: e ? Moment(e).format(dayFormat) : ''
    })
    // 就诊类型：
    // <Select value={admTypeCode} onChange={this.handleAdmTypeCodeChange} showSearch optionFilterProp="seatchprop" allowClear placeholder="请选择" style={{ width: '150px', margin: '22px 10px 0 0' }}>
    //   {admTypeOption}
    // </Select>
  }

  handleAdmSTDEndChange = (e) => {
    this.setState({
      admSPDate: e ? Moment(e).format(dayFormat) : ''
    })
  }

  // 一键回退
  handleBackOff = () => {
    let { rowId } = this.state;
    if (!rowId) {
      message.info("请选择需要操作的患者！！！")
      return;
    }
    let data = {
      params: [{
        statusCode: "R",
        type: "ALL",
        admID: rowId,
      }]
    }
    $http.post('urlS', this, {
      code: "06050022",
      data: data,
      success: function (res) {
        if (+res.errorCode === 0) {
          // userData && userData.messageTime ? userData.messageTime : 3
          message.success(res && res.errorMessage ? res.errorMessage : "一键回退成功");
          this.getTableData();
          this.getPatEMRCurrentStatus();
          this.getPatEMRCurrentStatus("R");
          // this.getTableData("noRefresh");
          // 刷新目录树数据
          // this.caseInformationPageHospitalChild && this.caseInformationPageHospitalChild.getTreeData && this.caseInformationPageHospitalChild.getTreeData("patientRecords");
        }
      }
    })
  }

  // 是否已提交
  handleIsSubmitChange = e => {
    this.setState({ isSubmit: e }, () => {
      this.handleQuery();
    })
  }
  //病历审核  【批量审核】
  handleAudit = () => {
    let { rowId, userData, selectedRowKeys } = this.state;
    // if (!rowId) return;
    if (selectedRowKeys.length === 0) {
      message.info("请选择需要病历审核的患者！！！")
      return
    }
    let data = {
      params: [{
        statusCode: "A",
        admID: selectedRowKeys,
      }]
    }
    $http.post('urlS', this, {
      code: "06050024",
      data: data,
      success: function (res) {
        if (+res.errorCode === 0) {
          message.success(res.errorMessage);
          this.getPatEMRCurrentStatus();
          this.getPatEMRCurrentStatus("R");
          /**刷新患者列表数据 */
          this.handleQuery();
        }
      }
    })
  }
  //显示病案号输入框
  showModal = () => {
    this.setState({
      visible: true,
    })
  }
  ///隐藏病案号输入框
  hideModal = () => {
    this.setState({
      visible: false,
    })
  }
  //病历归档
  handleArchived = () => {
    let { rowId, userData, admMedicalNo } = this.state;
    if (!rowId) {
      message.info("请选择需要操作的患者！！！")
      return;
    }
    let data = {
      params: [{
        statusCode: "AR",
        admID: rowId,
        admMedicalNo: admMedicalNo,
      }]
    }
    $http.post('urlS', this, {
      code: "06050024",
      data: data,
      success: function (res) {
        message.success(res.errorMessage);
        this.hideModal();
        if (+res.errorCode === 0) {
          this.getPatEMRCurrentStatus();
          this.getPatEMRCurrentStatus("R");
          /**刷新患者列表数据 */
          this.handleQuery();
        }
      }
    })
  }

  /**多选行操作修改 */
  onSelectChange = selectedRowKeys => {
    // console.log('selectedRowKeys changed: ', selectedRowKeys);
    let { tableData } = this.state
    let newSelRowKeys = selectedRowKeys.filter((item) => {
      let flag = false
      for (let index = 0; index < tableData.length; index++) {
        const tabData = tableData[index]
        if (tabData.admID == item) {
          if (tabData.EMRStatusedCode === "F") { flag = true }
          break
        }
      }
      return flag
    })
    // console.log("newSelRowKeys:"+newSelRowKeys)
    this.setState({ selectedRowKeys: newSelRowKeys });
  };

  handleCaseInformationPageHospitalRef = ref => {
    this.caseInformationPageHospitalChild = ref;
  }

  render() {
    let { patientColumns, tableData, total, page, basicHeight, loading, patMessage, medicalNo, bedID, locID, patientWidth, bedData, locSelectData,
      medicalRecordTemplateSelectData, rowId, admStatusCode, admStatusSelectData, isSubmit, rowRow, admTypeSelectData, submitSelectData,
      admStatusAble, bedIDAble, medicalNoAble, docNameAble, locDocData, admDocID, selectedRowKeys
    } = this.state;

    // 床号
    var bedDataOption = []
    bedData && bedData.map((item, index) => {
      bedDataOption.push(<Option key={index} value={item.bedID} title={item.bedNo} seatchprop={item.bedNo}>
        {item.bedNo}
      </Option>)
    })

    // 
    var locOption = []
    locSelectData && locSelectData.map((item, index) => {
      locOption.push(<Option key={index} code={item.descriptsSPCode} value={item.id} seatchprop={item.descripts + '^' + item.descriptsSPCode} title={item.descripts}>{item.descripts}</Option>)
    })

    //科室医生
    var locDocDataOption = []
    locDocData && locDocData.map((item, index) => {
      locDocDataOption.push(<Option key={index} code={item.descriptsSPCode} value={item.id} seatchprop={item.descripts + '^' + item.descriptsSPCode} title={item.descripts}>{item.descripts}</Option>)
    })

    // 病历模板
    var medicalRecordTemplateOption = [];
    medicalRecordTemplateSelectData && medicalRecordTemplateSelectData.map((item, index) => {
      medicalRecordTemplateOption.push(<Option key={index} code={item.descriptsSPCode} value={item.id} seatchprop={item.descripts + '^' + item.descriptsSPCode} title={item.descripts}>{item.descripts}</Option>)
    })

    // 就诊类型
    let admTypeOption = [];
    admTypeSelectData && admTypeSelectData.map((item, index) => {
      admTypeOption.push(<Option key={index} code={item.admCode} value={item.admCode} seatchprop={item.admDesc + '^' + item.descriptsSPCode} title={item.admDesc}>{item.admDesc}</Option>)
    })

    // 患者类型
    let admStatusOption = [];
    admStatusSelectData && admStatusSelectData.map((item, index) => {
      admStatusOption.push(<Option key={index} code={item.descriptsSPCode} value={item.code} seatchprop={item.descripts + '^' + item.descriptsSPCode} title={item.descripts}>{item.descripts}</Option>)
    })

    // 提交状态
    let submitOption = [];
    submitSelectData && submitSelectData.map((item, index) => {
      submitOption.push(<Option key={index} code={item.descriptsSPCode} value={item.code} seatchprop={item.descripts + '^' + item.descriptsSPCode} title={item.descripts}>{item.descripts}</Option>)
    })

    //多选行
    const rowSelection = {
      selectedRowKeys,
      onChange: this.onSelectChange,
    }

    return (
      <div className="patient-medical-record-inquiry">
        <Row id="patient-medical-record-inquiry-basic" style={{ padding: '0 12px' }}>
          <Col span={24} className="input-padding-right">
            <Row style={{ marginBottom: '20px' }}>
              科室名称：
              <Select value={locID} disabled onChange={this.handleLocIDChange} showSearch optionFilterProp="seatchprop" allowClear placeholder="请选择" style={{ width: '150px', margin: '22px 10px 0 0' }}>
                {locOption}
              </Select>
              患者类型：
              <Select value={admStatusCode} onChange={this.handleAdmStatusCodeChange}
                disabled={admStatusAble}
                showSearch optionFilterProp="seatchprop" allowClear placeholder="请选择" style={{ width: '150px', margin: '22px 10px 0 0' }}>
                {admStatusOption}
              </Select>
              床号：
              <Select value={bedID} onChange={this.handleBedIDChange}
                disabled={bedIDAble}
                showSearch optionFilterProp="seatchprop" allowClear placeholder="请选择" style={{ width: '100px', margin: '22px 10px 0 0' }}>
                {bedDataOption}
              </Select>
              住院号：
              <Input value={medicalNo} allowClear
                disabled={medicalNoAble}
                onChange={this.handleMedicalNoChange}
                placeholder='请输入'
                onPressEnter={this.handleQuery}
                style={{ width: '150px', margin: '22px 10px 0 0' }}
              />
              人员标识：
              <Input value={patMessage} allowClear
                onChange={this.handlePatMessageChange}
                ref={this.myRef1}
                onPressEnter={this.handleQuery}
                placeholder='请输入病人信息'
                style={{ width: '150px', margin: '22px 10px 0 0' }}
              />
              主管医生：
              <Select value={admDocID} onChange={this.handleAdmDocChange}
                disabled={docNameAble}
                showSearch optionFilterProp="seatchprop" allowClear placeholder="请选择" style={{ width: '150px', margin: '22px 10px 0 0' }}>
                {locDocDataOption}
              </Select>
              {admStatusCode !== 'D' ? (<div style={{ display: 'inline-block', margin: '8px 10px 0 0' }}>
                <RangeDatePicker label={'就诊(入院)日期：'} format='YYYY-MM-DD' width='270px'
                  startChange={this.handleAdmSTDStartChange} endChange={this.handleAdmSTDEndChange} />
              </div>) : ""}
              {admStatusCode === 'D' ? (<div style={{ display: 'inline-block', margin: '8px 10px 0 0' }}>
                <RangeDatePicker label={'出院日期：'} format='YYYY-MM-DD' width='270px'
                  startChange={this.startChange} endChange={this.endChange} />
              </div>) : ""}
              <Button type="primary" style={{ marginTop: '8px', marginLeft: "10px" }} onClick={this.handleQuery}>查询</Button>
            </Row>
          </Col>
        </Row>
        <div style={{ height: '6px', background: 'rgba(240, 242, 245, 1)', width: '100%' }}></div>
        <Row>
          <Col span={6}>
            <div style={{ paddingRight: '6px', position: 'relative' }}>
              <Card
                size="small"
                title={<div className="card-title-left-img" style={{ height: "32px" }}><img src={iconListvisits} alt="" />患者列表</div>}
              >
                <div>
                  <Table
                    columns={patientColumns && patientColumns.length > 0 ? patientColumns : []}
                    dataSource={tableData}
                    style={{ height: store.getState().tableHeight.y + 125 - basicHeight + 'px', }}
                    scroll={{ x: patientWidth, y: store.getState().tableHeight.y + 79 - basicHeight }}
                    rowSelection={rowSelection}
                    onRow={this.onClickRowPublic}
                    rowClassName={this.setRowClassNamePublic}
                    onHeaderRow={() => {
                      return {
                        onDoubleClick: () => {
                          this.columnRef.onOpenModel();
                        },
                      };
                    }}
                    bordered
                    rowKey={(data) => {
                      return data.admID
                    }}
                    pagination={false}
                    className="table-body-height" />
                  <CommonPagination current={page} total={total} search="search" pageSize="50"
                    onShowSizeChange={this.handleLeftShowSizeChange} complete={true} dataSource={tableData} size='small'
                    loading={loading} onChange={this.handleLeftChange} />
                </div>
              </Card>
              <div style={{ width: '6px', background: 'rgba(240, 242, 245, 1)', position: 'absolute', top: 0, right: 0, height: '100%' }}></div>
            </div>
          </Col>
          <Col span={18}>
            {rowId && rowRow && rowRow.admTypeCode == 'I' ? <CaseInformationPageHospital
              hideTabs={true}
              onRef={this.handleCaseInformationPageHospitalRef}
              //   editorID="POfPMRWriterControlHospital"
              isBasicOperation={false}
              prCont="Y"
              isDidUpdate="Y"
              caseInformationPageTabs="N"
              historyAdmID={rowId}
              locID={rowRow && rowRow.locID ? rowRow.locID : locID}
              //   fGroup="previewEMRRec"
              //   componentSource="PreviewOfPatientsMedicalRecord" // 组件来源
              clpHeader={store.getState().tableHeight.y + 241 - basicHeight - 4 + 'px'}
              // isOperable="N"
            /> : (rowId && rowRow && rowRow.admTypeCode == 'O' ? <CaseInformationPage
              //   editorID="POfPMRWriterControl"
              isDidUpdate="Y"
              isBasicOperation={false}
              caseInformationPageTabs="N"
              historyAdmID={rowId}
              locID={rowRow && rowRow.locID ? rowRow.locID : locID}
              //   fGroupTempByInfo="previewEMRRec"
              //   fGroup="previewEMRRec"
              //   componentSource="PreviewOfPatientsMedicalRecord"
              clpHeader={store.getState().tableHeight.y + 241 - basicHeight - 4 + 'px'}
              // isOperable="N"
            /> : "")}
          </Col>
        </Row>
        <ColumnAuthoritysModel
          clientWidth='800px'
          compontName="PreviewOfPatEMRPatList"
          configType="C"
          onRef={this.onColumnRef}
          reloadData={this.getPatientColumns}
        />
        <Modal
          title="请输入病案号"
          visible={this.state.visible}
          onOk={this.handleArchived}
          onCancel={this.hideModal}
        >
          <div style={{ display: 'flex', flexDirection: 'row' }}>
            <div style={{ height: "32px", lineHeight: "32px" }}>病案号:</div><Input
              value={this.state.admMedicalNo}
              onChange={this.handleAdmMedicalNoChange}
              placeholder='请输入病案号'
              style={{ width: '400px' }} />
          </div>
        </Modal>
      </div>
    );
  }
}

export default PreviewPatientEMRRecord;